package mk.company.fin.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
//import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import mk.company.fin.FinConstants;

@Entity
@Table(name = FinConstants.Tables.ORGANIZATION_SECTOR)
public class OrganizationSector extends Model {

	private static final long serialVersionUID = -2111591192227453205L;

	// persistent
	private Long id;
	private String code;
	private String description;
	private Organization organization;
	private List<NalogEntry> nalogEntries;
	
	
	@Id
	@Column(name = "id_organization_sector")
	@GeneratedValue//(strategy = GenerationType.SEQUENCE)
	public Long getId() {
		return id;
	}
	
	public void setId(Long id) {
		this.id = id;
	}

	@Column(unique = true, length = 20, nullable = false)
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Column
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinColumn(name = "id_organization", nullable = false)
	public Organization getOrganization() {
		return organization;
	}

	public void setOrganization(Organization organization) {
		this.organization = organization;
	}

	@OneToMany(mappedBy = "organizationSector", orphanRemoval = false, fetch = FetchType.LAZY)
	public List<NalogEntry> getNalogEntries() {
		return nalogEntries;
	}

	public void setNalogEntries(List<NalogEntry> nalogEntries) {
		this.nalogEntries = nalogEntries;
	}
	

}
